package xyz.lovegu.server.sys.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.lovegu.server.sys.common.ResultMessage;
import xyz.lovegu.server.sys.common.ResultObj;
import xyz.lovegu.server.sys.common.ResultUtil;
import xyz.lovegu.server.sys.service.ClassesService;
import xyz.lovegu.server.sys.vos.ClassesVo;

/**
 * @author 老顾
 * @title: ClassesController
 * @projectName campus-prevention-system
 * @email: 1437594522@qq.com
 * @date 2022/5/9 22:50
 */
@Validated
@RestController
@RequestMapping("sys/classes")
@RequiredArgsConstructor
public class ClassesController {

    private final ClassesService classesService;

    @PostMapping("addClasses")
    public ResultMessage<ResultObj> addClasses(@RequestBody ClassesVo classesVo) {
        return ResultUtil.data(classesService.addClasses(classesVo));
    }

    @PostMapping("deleteClassesById")
    public ResultMessage<ResultObj> deleteClassesById(@RequestBody ClassesVo classesVo) {
        return ResultUtil.data(classesService.deleteClassesById(classesVo));
    }

    @PostMapping("deleteBatchClasses")
    public ResultMessage<ResultObj> deleteBatchClasses(@RequestBody ClassesVo classesVo) {
        return ResultUtil.data(classesService.deleteBatchClasses(classesVo));
    }

    @PostMapping("updateClasses")
    public ResultMessage<ResultObj> updateClasses(@RequestBody ClassesVo classesVo) {
        return ResultUtil.data(classesService.updateClasses(classesVo));
    }

    @GetMapping("getClassesById")
    public ResultMessage<Object> getClassesById(@RequestParam("id") Integer id) {
        return ResultUtil.data(classesService.getClassesById(id));
    }

    @GetMapping("getAllClasses")
    public ResultMessage<Object> getAllClasses(ClassesVo classesVo) {
        return ResultUtil.data(classesService.getAllClasses(classesVo));
    }
}
